﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameStudio.Common.Enumerations;

namespace GameStudio.Common.DocView
{
    public class DocumentBase : IDocument, IFile
    {
        private ViewsCollection _views;

        public DocumentBase()
        {
            _views = new ViewsCollection();
        }

        #region IDocument Members

        public IFile File
        {
            get { return this; }
        }

        public ICollection<IView> Views
        {
            get { return _views; }
        }

        public void UpdateViews()
        {
            this.IsChanged = true;
            _views.ForEach(view => view.Update());
        }

        public void Save()
        {
            this.IsChanged = false;
            this.File.Save();
        }

        public bool IsChanged { get; set; }

        public void Close()
        {
            if (IsChanged)
                Save();
        }

        #endregion

        #region IFile Members

        public string Name
        {
            get { throw new NotImplementedException(); }
        }

        #endregion
    }
}
